Image processor

ABSTRACT

The present invention relates to an image processing apparatus, and to realize improved lossless compression of images more efficiently. A first predictor  11  generates a prediction signal P out of peripheral pixel values supplied from a pixel sequence generator  2.  A second predictor  12  generates a prediction signal Q out of the peripheral pixel values supplied from the pixel sequence generator  2.  An adder  4  subtracts the prediction signal P from the current pixel value to thereby calculate a prediction error signal M. When the prediction signal Q is greater than the prediction signal P, an inverter  14  inverts the polarity of the prediction error signal M to consequently generate a prediction error signal N. And an entropy encoder  5  allocates a code word in accordance with the prediction error signal N generated by the inverter  14.

TECHNICAL FIELD

[0001] The present invention relates to an image processing apparatus,and more particularly to an apparatus capable of compressing, forexample, images efficiently without any loss.

BACKGROUND ART

[0002] It is usual recently that, in apparatus for handling image data,compression of image data is executed so as to reduce the amount of datato be stored or transmitted. For example, there is employed technologyof lossless compression (in saving information).

[0003] In the known lossless compression technology, there are methodsof CALIC, JPEG-LS and so forth.

[0004] Regarding the compression method known as CALIC (A Context-based,Adaptive, Lossless Image Codec), the details thereof are disclosed in,e.g., X. Wu and N. Memon, “Context-Based, Adaptive, Lossless ImageCoding, IEEE Transactions on Communications”, Vol. 45, No. 4, April1997, pp. 437-444.

[0005] Meanwhile, regarding the other compression method known asJPEG-LS (Joint Photographic Experts Group Lossless), the details thereofare disclosed in, e.g., “Lossless and Near-Lossless Coding of ContinuousTone Still Images”, ISO/IEC JTC1/SC29 WG1 14495.

[0006] In the compression methods of CALIC and JPEG-LS, there is adoptedDPCM (Differential Pulse Code Modulation), wherein pixels of each imageare scanned per row (line) and per column. The DPCM is a technique ofpredicting a subject pixel from peripheral pixels and encoding aprediction error signal thereof. It is capable of encoding the signalwithout impairing the information amount of the original image.

[0007] When such lossless compression is executed, a prediction signalis calculated, with regard to individual pixels, on the basis ofperipheral pixel values around each pixel (subject pixel). An entropyencoder encodes the prediction error signal of the calculated pixelvalue, i.e., the difference between the prediction signal and theeffective pixel value (actual signal).

[0008]FIG. 1 is a block diagram for explaining a conventional losslessimage compressing apparatus.

[0009] In an image buffer 1, there is stored an image inputted from anunshown external device. A pixel sequence generator 2 scans the imagestored in the image buffer 1, then extracts, with regard to each pixel,peripheral pixels from the current subject pixel, and supplies the valueof the current subject pixel to an adder 4 while supplying the values ofthe generated peripheral pixels to a predictor 3.

[0010] The predictor 3 generates a prediction signal on the basis of theperipheral pixel values obtained from the pixel sequence generator 2,and then supplies the prediction signal to the adder 4. Subsequently theadder 4 subtracts the prediction signal, which has been supplied theretofrom the predictor 3, from the current pixel value obtained from thepixel sequence generator 2, and supplies a prediction error signal to anentropy encoder 5.

[0011] Details of a simplified effective predictor 3 are disclosed in,e.g., S. Martucci, “Reversible Compression of HDTV Images using MedianAdaptive Prediction and Arithmetic Coding”, IEEE 1990.

[0012] The entropy encoder 5 generates a compressed code word from thesequence of the prediction error signal supplied from the adder 4, andthen outputs such a code word.

[0013] The prediction error signal is encoded as a variable-lengthprefix and a fixed-length suffix. The variable-length prefix is composedof a series of “0” bits that succeed a “1” bit. The sequence of theprediction error signal is divided by block. In each block, the optimallength of the suffix is decided first, and a code word is transmittedprior to being combined with the individual prediction error signal ofthe block.

[0014] Details of the entropy encoder 5 are disclosed in, e.g., R. Rice,“Lossless Coding Standards for Space Data Systems”, IEEE 1997.

[0015] However, since the known lossless compression methods describedabove is dependent on the past prediction progress, there exists aproblem that a memory is required for storing the past predictionprogress.

DISCLOSURE OF INVENTION

[0016] The present invention has been made in view of the circumstances.And it is an object of the invention to realize more efficient losslesscompression of images by selectively inverting the polarity of aprediction error signal without maintaining the past predictionprogress.

[0017] An image processing apparatus of the present invention includesfirst generator for measuring the pixel values of three peripheralpixels adjacent to a subject pixel currently, and generating a firstprediction signal from the measuring result; second generator forgenerating a second prediction signal which represents the average valueof the maximum and the minimum out of the measured values of the threeperipheral pixels; calculator for calculating a prediction error signalon the basis of the first prediction signal generated by the firstgenerator and the pixel-value of the subject pixel; comparator forcomparing the first prediction signal generated by the first generatorwith the second prediction signal generated by the second generator;inverter for inverting, on the basis of the comparison result obtainedfrom the comparator, the polarity of the prediction error signalcalculated by the calculator; and invertercode word allocator forallocating a code word in accordance with the prediction error signalinverted in polarity by the inverter.

[0018] The first generator measures the values A, B and A+B−C from therespective values A, B and C of the three peripheral pixels, andgenerates the intermediate value thereof as a first prediction signal.

[0019] When the first prediction signal generated by the first generatoris greater than the second prediction signal generated by the secondgenerator, the inverter may be capable of not inverting the polarity ofthe prediction error signal.

[0020] The peripheral pixels may consist of the pixel on the left sideof the subject pixel, the pixel on the upper side of the subject pixel,and the pixel on the upper left side of the subject pixel.

[0021] The first generator may be a median adaptive predictor.

[0022] An image processing method of the present invention includes afirst generation step of measuring the pixel values of three peripheralpixels adjacent to a subject pixel currently, and generating a firstprediction signal from the measuring result; a second generation step ofgenerating a second prediction signal which represents the average valueof the maximum and the minimum out of the measured values of the threeperipheral pixels; a calculation step of calculating a prediction errorsignal on the basis of the first prediction signal generated by theprocess at the first generation step and the pixel value of the subjectpixel; comparison step of comparing the first prediction signalgenerated by the process at the first generation step with the secondprediction signal generated by the process at the second generationstep; an inversion control step of controlling, on the basis of thecomparison result obtained by the process at the comparison step,inversion of the polarity of the prediction error signal calculated bythe process at the calculation step; and a code word allocation step ofallocating a code word in accordance with the prediction error signalcontrolled, with regard to inversion of its polarity, by the process atthe inversion control step.

[0023] The first generator step measures the values A, B and A+B−C fromthe respective values A, B and C of the three peripheral pixels, andgenerates the intermediate value thereof as a first prediction signal.

[0024] When the first prediction signal generated by the process at thefirst generation step is greater than the second prediction signalgenerated by the process at the second generation step, the polarity ofthe prediction error signal is not inverted at the inversion controlstep.

[0025] When the first prediction signal generated by the process at thefirst generation step is smaller than the second prediction signalgenerated by the process at the second generation step, the polarity ofthe prediction error signal is inverted at the inversion control step.

[0026] The peripheral pixels are composed of the pixel on the left sideof the subject pixel, the pixel on the upper side of the subject pixel,and the pixel on the upper left side of the subject pixel.

[0027] In the present invention, the intermediate value of threeperipheral pixels adjacent to the subject pixel currently is measured togenerate a first prediction signal from the measuring result, and theaverage value of the maximum and the minimum out of the measured valuesof the three peripheral pixels is generated as a second predictionsignal. Then a prediction error signal is calculated on the basis of thefirst prediction signal and the pixel value of the subject pixel, andthe polarity of the prediction error signal thus calculated is invertedon the basis of the result of comparing the first prediction signal withthe second prediction signal. And subsequently a code word is allocatedin accordance with the prediction error signal.

BRIEF DESCRIPTION OF DRAWINGS

[0028]FIG. 1 is a block diagram showing a structural example of aconventional lossless image compressing apparatus.

[0029]FIG. 2 is a block diagram showing a structural example of alossless image compressing apparatus where the present invention isapplied.

[0030]FIG. 3 is a diagram for explaining the positional relationshipbetween peripheral pixels and a subject pixel.

[0031]FIG. 4 shows an example of a correspondence table.

[0032]FIG. 5 shows an example of a code word conversion table.

[0033]FIG. 6 is a block diagram showing a structural example of anotherlossless image compressing apparatus where the present invention isapplied.

[0034]FIG. 7 is a diagram for explaining how to measure pixel values.

BEST MODE FOR CARRYING OUT THE INVENTION

[0035]FIG. 2 is a block diagram showing a structural example of alossless image compressing apparatus where the present invention isapplied. In this diagram, any component parts corresponding to those inthe conventional apparatus are denoted by the same reference numerals,and a repeated explanation thereof is omitted here.

[0036] A pixel sequence generator 2 scans an image stored in an imagebuffer 1, then generates, with regard to each pixel, peripheral pixels(25 in FIG. 3(B)) from a subject pixel (21 in FIG. 3(A)) currently, andsupplies the current pixel value to an adder 4 while supplying thegenerated peripheral pixel values to a first predictor 11 and a secondpredictor 12 respectively.

[0037] The first predictor 11 consists, for example, of a medianadaptive predictor. It generates a prediction signal P on the basis ofthe peripheral pixel values of the peripheral pixels 25 (FIG. 3(B))obtained from the pixel sequence generator 2, and then supplies theprediction signal P to a comparator 13 and the adder 4. And actuation ofthe first predictor 11 starts up the second predictor 12.

[0038] Referring now to FIG. 3, an explanation will be given on thepositional relationship between the peripheral pixels 25 and the subjectpixel 21 used in generating a prediction signal.

[0039] The subject pixel (X) 21 indicates a current pixel having a valueX. The peripheral pixel (A) 22 on the left side of the subject pixel (X)21 has a value A, and the peripheral pixel (B) 23 on the upper side ofthe subject pixel (X) 21 has a value B. And another peripheral pixel (C)24 on the upper left side of the subject pixel (X) 21 has a value C.Hereinafter these peripheral pixels 22 to 24 will be referred to simplyas peripheral pixels 25 (FIG. 3(B)).

[0040] The first predictor 11 executes prediction from the peripheralpixels 25. That is, the first predictor 11 measures a value A, a value Band a value (A+B−C) from the peripheral pixel (A) 22, the peripheralpixel (B) 23 and the peripheral pixel (C) 24 respectively, and thendetermines a prediction signal P which represents the intermediate valueof the three measured values A, B and (A+B−C). It should be noted thatthe first predictor 11 has the same configuration as the predictor 3explained in FIG. 1.

[0041] The second predictor 12 is started up in response to a startrequest received from the first predictor 11, and calculates aprediction signal Q according to Eq. (1), which is shown below, from theperipheral pixel (A) 22, the peripheral pixel (B) 23 and the peripheralpixel (C) 24 supplied from the pixel sequence generator 2.

Prediction signal Q=(min (A, B, C)+max (A, B, C))/2  . . . (1)

[0042] The second predictor 12 supplies to a comparator 13 theprediction signal Q calculated according to Eq. (1).

[0043] The comparator 13 compares the prediction signal P obtained fromthe first predictor 11 with the prediction signal Q obtained from thesecond predictor 12, and then delivers its output (result of suchcomparison) to an inverter 14. The output delivered here representsinformation that signifies whether the prediction signal P is greater ornot than the prediction signal Q.

[0044] On the basis of the output thus delivered from the comparator 13,the inverter 14 inverts, when necessary, the polarity of a predictionerror signal A (residual) outputted from the adder 4, and then deliversa prediction error signal N to an entropy encoder 5.

[0045] In the embodiment of the present invention, the inverter 14inverts the polarity of the prediction error signal M when the outputdelivered from the comparator 13 indicates that the prediction signal Pis smaller than the prediction signal Q. Further, the inverter 4 keepsthe polarity of the prediction error signal M unchanged (withoutinversion) when the output delivered from the comparator 13 indicatesthat the prediction signal P is greater than the prediction signal Q.

[0046] Details of a method for selectively inverting the polarity of theprediction error signal to enhance the compression efficiency aredisclosed in, e.g., X. Wu, “Lossless Compression of Continuous-ToneImages via Context Selection, Quantization, and Modeling”, IEEETransactions on Image Processing, Vol. 6, No. 5, May 1997, pp. 656-664.

[0047] In order to utilize the procedure of sign inversion, the entropyencoder 5 allocates, on the basis of the value of the prediction errorsignal N supplied from the inverter 14, either a code word shorter thana positive value equal in magnitude to the prediction error signal N ora code word equal in length to the prediction error signal N.

[0048] Details of such entropy encoder 5 are disclosed in, e.g., ISO/IECJTC1/SC29 WG1 14495, “Lossless and Near Lossless Coding of ContinuousTone Still Images”.

[0049] Next, an explanation will be given on the operation performed inthe embodiment mentioned above.

[0050] The pixel sequence generator 2 scans the image stored in theimage buffer 1, then generates peripheral pixels 22 to 24 from thesubject pixel 21 (FIG. 3(A)) currently, and supplies the current pixelvalue X (e.g. “7”) to the adder 4. The pixel values of the peripheralpixels 22 to 24 generated by the pixel sequence generator 2 are suppliedto both the first predictor 11 and the second predictor 12. Now theoperation will be described below under the condition that theperipheral pixel 22 has a pixel value A of “10”, the peripheral pixel 23has a pixel value B of “2”, and the peripheral pixel 24 has a pixelvalue C of “7”, respectively.

[0051] The first predictor 11 measures the values A, B and (A+B−C) fromthe peripheral pixels 22 to 24 supplied from the pixel sequencegenerator 2, and generates a prediction signal A which corresponds tothe intermediate value thereof.

[0052] That is, since

A=10, B=2

and

(A+B−C)=(10+2−7)=5,

[0053] the intermediate value “5” is determined as a prediction signalP.

[0054] The second predictor 12 calculates, according to Eq. (1), aprediction signal Q out of the peripheral pixels 22 to 24 supplied fromthe pixel sequence generator 2.

[0055] That is, a value “6” is calculated as a prediction signal Q from

(min (A,B,C)+max (A,B,C))/2=(min (10,2,7)+max (10,2,7))/2=(2+10)/2=6.

[0056] The prediction signal P calculated by the first predictor 11 andthe prediction signal Q calculated by the second predictor 12 aresupplied to the comparator 13. Meanwhile, the prediction signal Pcalculated by the first predictor 11 is supplied also to the adder 4.

[0057] The comparator 13 compares the prediction signal P supplied fromthe first predictor 11 with the prediction signal Q supplied from thesecond predictor 12, and then delivers its output (result of suchcomparison) to the inverter 14.

[0058] Subsequently the adder 4 subtracts the prediction signal P (“5”in this case), which has been obtained from the first predictor 11, fromthe current pixel value X (“7” in this case) obtained from the pixelsequence generator 2, and then supplies a prediction error signal M tothe inverter 14. In this example, the value of the prediction errorsignal M becomes “2” as a result of 7−5=2.

[0059] On the basis of the output delivered from the comparator 13, theinverter 14 inverts, when necessary, the polarity of the predictionerror signal M (residual) obtained from the adder 4, and then supplies aprediction error signal N to the entropy encoder 5.

[0060] For example, in case the prediction signal Q outputted from thesecond predictor 12 is greater than the prediction signal P outputtedfrom the first predictor 11, the actual measured value of the pixel(pixel value) becomes further greater than the prediction signal Qoutputted from the second predictor 12, so that the prediction errorsignal M is rendered positive in value. That is, in case the predictionsignal P is greater than the prediction signal Q, the prediction errorsignal M is rendered reverse in polarity to the prediction error signalN.

[0061] Further, in case the prediction signal Q outputted from thesecond predictor 12 is smaller than the prediction signal P outputtedfrom the first predictor 11, the actual measured value of the pixelbecomes further smaller than the prediction signal Q outputted from thesecond predictor 12, so that the prediction error signal P is renderednegative in value. That is, when the prediction signal P is smaller thanthe prediction signal Q, the prediction error signal M is rendered thesame in polarity as the prediction error signal N.

[0062] That is, in the case of this example, the value “6” of theprediction signal Q outputted from the second predictor 12 is greaterthan the value “5” of the prediction signal P outputted from the firstpredictor 11, so that the value “2” of the prediction error signal M isinverted in polarity to consequently obtain a value “−2”.

[0063] Thus, when the value of the prediction signal Q is greater thanthe value of the prediction signal P, the prediction error signal M isinverted in polarity to thereby increase the possibility that thepolarity of the prediction error signal N becomes negative, as a result,enhancing the compression efficiency.

[0064] The entropy encoder 5 determines, on the basis of the predictionerror signal N supplied from the inverter 14, a corresponding value inaccordance with a correspondence table shown in FIG. 4, then generates acode word from the corresponding value thus determined, according to acode word conversion table shown in FIG. 5, and outputs the generatedcode word.

[0065] In the example of FIG. 4, when the prediction error signal N is“0”, its corresponding value is set to “0”. When the prediction errorsignal N is “−1”, its corresponding value is set to “1”. When theprediction error signal N is “1”, its corresponding value is set to “2”.When the prediction error signal N is “−2”, its corresponding value isset to “3”. When the prediction error signal N is “2”, its correspondingvalue is set to “4”. When the prediction error signal N is “−3”, itscorresponding value is set to “5”. When the prediction error signal N is“3”, its corresponding value is set to “6”. When the prediction errorsignal N is “−4”, its corresponding value is set to “7”. When theprediction error signal N is “4”, its corresponding value is set to “8”.When the prediction error signal N is “−5”, its corresponding value isset to “9”. When the prediction error signal N is “5”, its correspondingvalue is set to “10”. When the prediction error signal N is “−6”, itscorresponding value is set to “11”. When the prediction error signal Nis “6”, its corresponding value is set to “12”. When the predictionerror signal N is “−7”, its corresponding value is set to “13”. When theprediction error signal N is “7”, its corresponding value is set to“14”. And when the prediction error signal N is “−8”, its correspondingvalue is set to “15”.

[0066] In the example of FIG. 5, when the corresponding value is “0”,the code word is first converted into “1”, and it is further convertedinto “10” as an output code word. When the corresponding value is “1”,the code word is first converted into “01”, and it is further convertedinto “11” as an output code word. When the corresponding value is “2”,the code word is first converted into “001”, and it is further convertedinto “010” as an output code word. When the corresponding value is “3”,the code word is first converted into “0001”, and it is furtherconverted into “011” as an output code word. When the correspondingvalue is “4”, the code word is first converted into “00001”, and it isfurther converted into “0010” as an output code word. When thecorresponding value is “5”, the code word is first converted into“000001”, and it is further converted into “0011” as an output codeword. When the corresponding value is “6”, the code word is firstconverted into “0000001”, and it is further converted into “00010” as anoutput code word. And when the corresponding value is “7”, the code wordis first converted into “00000001”, and it is further converted into“00011” as an output code word.

[0067] Therefore, in the case of this example where the prediction errorsignal N is “−2”, the corresponding value thereof is set to “3”according to the correspondence table shown in FIG. 4. This value isconverted into “0001” as a code word corresponding to the value “3”,according to the code word conversion table shown in FIG. 5, and thenfurther converted into “011” as an output code word.

[0068] In case the prediction error signal N is “2” for example, thecorresponding value thereof is set to “4” according to thecorrespondence table shown in FIG. 4. This value is converted into“00001” as a code word corresponding to the value “4”, according to thecode word conversion table shown in FIG. 5, and then further convertedinto “0010” as an output code word.

[0069] Thus, when the prediction error signal N has been inverted inpolarity, a shorter code word is allocated. Meanwhile, if the predictionerror signal N has not been inverted in polarity, a longer code word isallocated.

[0070] A coding rate of the lossless compression of images can beimproved by adaptively inverting the prediction error signal M asdescribed above. As for the mechanism of polarity inversion in thiscase, more efficient compression is executable by a prediction errorsignal M of a negative value.

[0071] For the purpose of enhancing the coding efficiency, the entropyencoder 5 can generate a shorter code word by utilizing the bias of thepolarity of the prediction error signal M.

[0072]FIG. 6 is a block diagram showing a structural example of anotherlossless image compressing apparatus where the present invention isapplied. In this diagram, any component parts corresponding to those inFIG. 2 are denoted by the same reference numerals, and a repeatedexplanation thereof is omitted here. In this structural example, a blockunit 41 is provided between an image buffer 1 and a pixel sequencegenerator 2, and an average calculating unit 42 is provided as an outputdestination of the block unit 41. Any other structure is the same asthat in FIG. 2.

[0073] The block unit 41 divides the image, which is stored in the imagebuffer 1, into blocks each composed of 6×6 pixels for example, andsupplies each block 61 (FIG. 7) to the pixel sequence generator 2 whilesupplying the block 61 also to the average calculating unit 42.

[0074] The pixel sequence generator 2 scans the block 61 (FIG. 7)supplied from the block unit 41, then extracts, with regard to eachpixel, peripheral pixels (22 to 24 in FIG. 7(A)) from a subject pixel(21 in FIG. 7(A)) currently and supplies the current pixel value to anadder 4 while supplying the generated peripheral pixel values to a firstpredictor 11 and a second predictor 12 respectively.

[0075] The average calculating unit 42 calculates the average value ofthe block 61 (FIG. 7) supplied thereto from the block unit 41, andsupplies the calculated average value to the first predictor 11, thesecond predictor 12 and the pixel sequence generator 2 respectively.

[0076] The first predictor 11 calculates a prediction signal P on thebasis of the peripheral pixel values of the peripheral pixels 25 (FIG.3(B)) supplied from the pixel sequence generator 2, and then suppliesthe signal P to a comparator 13 and the adder 4 respectively.

[0077] The second predictor 12 calculates a prediction error signal N onthe basis of the peripheral pixel values of the peripheral pixels 25(FIG. 3(B)) supplied from the pixel sequence generator 2, and also onthe basis of the average value supplied from the average calculatingunit 42.

[0078] Next, an explanation will be given on the operation performed inthe above embodiment.

[0079] The average calculating unit 42 calculates the average value ofthe block 61 (FIG. 7) supplied thereto from the block unit 41. Here, theaverage value is defined as the value divided by the number of pixels inthe block into the total value of the entire pixels in the block 61. Asfor the average calculation method executed by the average calculatingunit 42, the prediction signal P is furnished as an upper left sample ofthe block 61, or the prediction signal Q is furnished selectively.

[0080] The pixel sequence generator 2 scans the image stored in theimage buffer, then extracts peripheral pixels 25 from the subject pixel21 (FIG. 3(A)) currently, and supplies the current pixel value X to theadder 4. The pixel values of the peripheral pixels 25 generated by thepixel sequence generator 2 are supplied to the first predictor 11 andthe second predictor 12 respectively.

[0081] In case the peripheral pixels 22 to 24 adjacent to the subjectpixel 21 are within the boundary of the block 61 as shown in FIG. 7(A),it is possible to measure the individual pixel values, so that the pixelsequence generator 2 is enabled to output the pixel values of theperipheral pixels 22 to 24 individually.

[0082] However, if the subject pixel 21 is on a row 62 as shown in FIG.7(B), the peripheral pixels 23 and 24 are outside the boundary of theblock 41, so that it is impossible to measure the pixel values. In sucha case, therefore, the pixel sequence generator 2 allocates the averagevalue, which is supplied from the average calculating unit 42, to thepixel values of the peripheral pixels 23 and 24.

[0083] In another case where the subject pixel 21 is on a column 63 asshown in FIG. 7(C), the peripheral pixels 22 and 24 are outside theboundary of the block 61, so that it is impossible to measure the pixelvalues as in the case of FIG. 7(B). In this case, therefore, the pixelsequence generator 2 allocates the average value, which is supplied fromthe average calculating unit 42, to the pixel values of the peripheralpixels 22 and 24.

[0084] The first predictor 11 generates a prediction signal P on thebasis of the peripheral pixels 22 to 24 supplied from the pixel sequencegenerator 2. That is, as described above, the first generator 11measures the values A, B and A+B−C from the peripheral pixels (A) 22,peripheral pixels (B) 23, and peripheral pixels (C) 24, and determinesthe intermediate value of A, B and C of the three peripheral pixels, asa prediction signal P.

[0085] The second predictor 12 generates a prediction signal Q on thebasis of the peripheral pixels 22 to 24 supplied from the pixel sequencegenerator 2, and also on the basis of the average value supplied fromthe average calculating unit 42. First, the second predictor 12, asdescribed above, calculates a value of Eq. (1) from the peripheralpixels (A) 22, peripheral pixels (B) 23, and peripheral pixels (C) 24.

[0086] That is, when the value obtained according to Eq. (1) isdifferent from the prediction signal P, the result of calculating Eq.(1) is given as the prediction signal Q. Meanwhile, when the valueobtained according to Eq. (1) is equal to the prediction signal P, theaverage value supplied from the average calculating unit 42 is given asthe prediction signal Q.

[0087] Since the operation performed thereafter is the same as thatdescribed in connection with FIG. 2, a repeated explanation thereof isomitted here.

[0088] The processing routine mentioned above is executable by softwareas well as by hardware. When the processing routine is to be executed bysoftware, the routine can be installed from a recording medium into,e.g., a computer where programs constituting the relevant software areincorporated in its exclusive hardware, or into a general-purposepersonal computer which is capable of executing various functions inaccordance with various program is installed therein.

[0089] This recording medium connotes a package one distributed forproviding programs to users separately from the computer, and itincludes a magnetic disk (including flexible disk), an optical disk(including CD-ROM (Compact Disk-Read Only Memory) and a DVD (DigitalVersatile Disk)), a magneto-optical disk (including MD (MiniDisk)(registered trademark)), or a semiconductor memory where programsare recorded. The recording medium may further include a ROM, a harddisk and so forth where programs are recorded and provided for users ina state incorporated previously in a computer.

[0090] In this specification, the steps that describe the program storedin the recording medium are executed in time series in accordance withthe mentioned sequence, or may be executed in parallel or individuallywithout being restricted to the time series processing.

Industrial Applicability

[0091] According to the present invention, as described hereinabove, thepixel value of three peripheral pixels adjacent to the subject pixelcurrently is measured to generate a first prediction signal from themeasuring result, and the average value of the maximum and the minimumout of the measured values of the three peripheral pixels is generatedas a second prediction signal. Then a prediction error signal iscalculated on the basis of the first prediction signal and the pixelvalue of the subject pixel, and the polarity of the prediction errorsignal thus calculated is inverted on the basis of the result ofcomparing the first prediction signal with the second prediction signal.And subsequently a code word is allocated in accordance with thecalculated prediction error signal, thereby realizing improved losslesscompression of images more efficiently.

1. An image processing apparatus for lossless compression of images, comprising: first generator for measuring the pixel values of three peripheral pixels adjacent to a subject pixel, and generating a first prediction signal from the measuring result; second generator for generating a second prediction signal which represents the average value of the maximum and the minimum out of the measured values of the three peripheral pixels; calculator for calculating a prediction error signal on the basis of the first prediction signal generated by said first generator and the pixel value of said subject pixel; comparator for comparing the first prediction signal generated by said first generator with the second prediction signal generated by said second generator; inverter for inverting, on the basis of the comparison result obtained from said comparator, the polarity of the prediction error signal calculated by said calculator; and invertercode word allocator for allocating a code word in accordance with the prediction error signal inverted in polarity by said inverter.
 2. The image processing apparatus according to claim 1, wherein said first generator measures the values A, B and A+B−C from the respective values A, B and C of said three peripheral pixels, and generates the intermediate value thereof as said first prediction signal.
 3. The image processing apparatus according to claim 1, wherein, when the first prediction signal generated by said first generator is greater than the second prediction signal generated by said second generator, said inverter does not invert the polarity of the prediction error signal.
 4. The image processing apparatus according to claim 1, wherein, when the first prediction signal generated by said first generator is smaller than the second prediction signal generated by said second generator, said inverter inverts the polarity of the prediction error signal.
 5. The image processing apparatus according to claim 1, wherein said peripheral pixels consist of the pixel on the left side of the subject pixel, the pixel on the upper side of the subject pixel, and the pixel on the upper left side of the subject pixel.
 6. The image processing apparatus according to claim 1, wherein said first generator is a median adaptive predictor.
 7. An image processing method carried out in an image processing apparatus for lossless compression of images, comprising: a first generation step of measuring the pixel values of three peripheral pixels adjacent to a subject pixel, and generating a first prediction signal from the measuring result; a second generation step of generating a second prediction signal which represents the average value of the maximum and the minimum out of the measured values of the three peripheral pixels; a calculation step of calculating a prediction error signal on the basis of the first prediction signal generated by the process at said first generation step and the pixel value of said subject pixel; comparison step of comparing the first prediction signal generated by the process at said first generation step with the second prediction signal generated by the process at said second generation step; an inversion control step of controlling, on the basis of the comparison result obtained by the process at said comparison step, inversion of the polarity of the prediction error signal calculated by the process at said calculation step; and a code word allocation step of allocating a code word in accordance with the prediction error signal controlled, with regard to inversion of its polarity, by the process at said inversion control step.
 8. The image processing method according to claim 7, wherein, at said first generation step, the values A, B and A+B−C are measured from the respective values A, B and C of said three peripheral pixels, and the intermediate value thereof is generated as said first prediction signal.
 9. The image processing method according to claim 7, wherein, when the first prediction signal generated by the process at said first generation step is greater than the second prediction signal generated by the process at said second generation step, the polarity of said prediction error signal is not inverted at said inversion control step.
 10. The image processing method according to claim 7, wherein, when the first prediction signal generated by the process at said first generation step is smaller than the second prediction signal generated by the process at said second generation step, the polarity of said prediction error signal is inverted at said inversion control step.
 11. The image processing method according to claim 7, wherein said peripheral pixels are composed of the pixel on the left side of said subject pixel, the pixel on the upper side of said subject pixel, and the pixel on the upper left side of said subject pixel. 